﻿' ------------------------------------------------------------------------------
' This form is displayed when the application is attempting to connect to SQL
' Server. It doesn't have a frame and acts as a splash screen when the application
' is starting up, while the initial connection is being made prior to the main
' form opening up.
' ------------------------------------------------------------------------------
' This file is part of the SQL Server 2008 Technology Demonstration. This
' application was designed and coded by Eric Weitzman, LandTime Inc, for
' Microsoft Corporation. Contact Ed Katibah at Microsoft about this demo.
' Copyright © 2008 Microsoft Corporation. All rights reserved.
' ------------------------------------------------------------------------------

Public Class ConnectSplashForm
    Inherits System.Windows.Forms.Form

    Public WriteOnly Property Message() As String
        Set(ByVal value As String)
            BeginInvoke(New DlgSetMessage(AddressOf PrivateSetMessage), value)
        End Set
    End Property
    Private Delegate Sub DlgSetMessage(ByVal value As String)
    Private Sub PrivateSetMessage(ByVal value As String)
        txtMessage.Text = value
    End Sub

    Public Sub ShowForm(ByVal show As Boolean)
        Try
            BeginInvoke(New DlgShowForm(AddressOf PrivateShowForm), show)
        Catch ex As Exception
            Try : Me.Visible = show : Catch : End Try
        End Try
    End Sub
    Private Delegate Sub DlgShowForm(ByVal show As Boolean)
    Private Sub PrivateShowForm(ByVal show As Boolean)
        Me.Visible = show
    End Sub

    Private Sub ConnectingStatusForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        e.Cancel = True
        Me.Visible = False
    End Sub

    Private Sub ConnectingStatusForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txtMessage.Visible = True
        g_splashconnect = Me
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Visible = False
    End Sub

    Private Sub ConnectingStatusForm_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        Me.BringToFront()
    End Sub
End Class